import { recommendArticle, recommendLiterature } from "../../../api/index"
import { wxNav } from "../../../utils/util";

// pages/tabBar/home/index.ts
Page({

    /**
     * 页面的初始数据
     */
    data: {
        articleData: [],
        literatureData: []
    },

    // 请求
    getData() {
        recommendArticle().then((r: any) => {
            this.setData({
                articleData: r
            });
        });
        recommendLiterature().then((r: any) => {
            this.setData({
                literatureData: r
            })
        })
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
        this.getData();
    },

    // 文章详情点击
    articleClick(e: { currentTarget: { dataset: { id: any; }; }; }) {
        const id = e.currentTarget.dataset.id;
        wxNav("/pages/article/detail/index?id="+id);  
    },
})